package com.bi.bitest.bao.adapters;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.bi.bitest.bao.R;
import com.bi.bitest.bao.entity.AlbumDetail.Tracks;

import java.util.List;

/**
 * Created
 * Author:bi[FR]
 * Date:15-10-24
 */
public class Item_listDetailAdapter extends BaseAdapter {


    private List<Tracks>datas;
    private Context context;
    public Item_listDetailAdapter(Context context, List<Tracks> datas){
        this.context=context;
        this.datas=datas;
    }
    @Override
    public int getCount() {
        int ret=0;
        if(datas!=null)
            ret=datas.size();
        return ret;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return datas.get(position).getTrackId();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView!=null){
            holder= (ViewHolder) convertView.getTag();
        }else{

            convertView= LayoutInflater.from(context).inflate(R.layout.item_listview_albumdetail,parent,false);
            holder=new ViewHolder();

            holder.tv_title= (TextView) convertView.findViewById(R.id.tv_title_item_list_albumdetail);
            holder.tv_createAt= (TextView) convertView.findViewById(R.id.tv_createAt_item_list_albumdetail);
            holder.tv_playtimes= (TextView) convertView.findViewById(R.id.tv_playtimes_item_list_albumdetail);
            holder.tv_duration= (TextView) convertView.findViewById(R.id.tv_duration_item_list_albumdetail);
            holder.tv_comments= (TextView) convertView.findViewById(R.id.tv_comments_item_list_albumdetail);
            convertView.setTag(holder);
        }

        holder.tv_title.setText(datas.get(position).getTitle());
        holder.tv_createAt.setText(datas.get(position).getCreatedAt()+"");
        holder.tv_playtimes.setText(datas.get(position).getPlaytimes()+"");
        holder.tv_duration.setText(datas.get(position).getDuration());
        holder.tv_comments.setText(datas.get(position).getComments()+"");

        return convertView;
    }


    private static class ViewHolder{
        TextView tv_title,tv_createAt,tv_playtimes,tv_duration,tv_comments;
    }


}
